﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MedicareDataAccess;
using MedicareModel;

namespace MedicareBusiness
{
    public class PatientBO
    {

        private PatientDAO patients = new PatientDAO(); 

        public void addPatient(Patient aPatient)
        {
            patients.createPatient(aPatient); 
        }

        public List<Patient> getAllPatients()
        {
            return patients.getAllPatients();
        }

        public void updatePatient(Patient aPatient)
        {
            patients.updatePatient(aPatient);
        }

        public Patient getPatientByID(int id)
        {
            return patients.getPatientByID(id);
        }

        public void processRequest(int id)
        {
            patients.requestProcessed(id); 
        }

        public void sendHelp(int id)
        {
            patients.helpOnTheWay(id); 
        }

        public List<Patient> searchPatients(int anOperator, string aCriteria)
        {
            switch (anOperator)
            {
                case 0:
                    return patients.getByLastName(aCriteria);

                case 1:
                    return patients.getBySSN(aCriteria);

                case 2:
                    return patients.getByDOB(aCriteria); 

                default:
                    return null;
            }
        }

        public String deletePatient(int idPatient)
        {
            EventDAO events = new EventDAO();

            if (events.eventsAssignedToThisPatient(idPatient))
            {
                return "Patient has events assigned - Cannot delete";
            }

            else
            {
                patients.deletePatient(idPatient);

                return "Patient deleted"; 
            }


        }

        public void resetPatient(int aPatientID)
        {
            patients.resetPatient(aPatientID); 
        }

    }
}
